package com.xveshe.admin.service.impl;

import java.util.List;
import java.util.UUID;

import com.xveshe.common.utils.DateUtils;
import com.xveshe.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xveshe.admin.mapper.XsglTgsqMapper;
import com.xveshe.admin.domain.XsglTgsq;
import com.xveshe.admin.service.IXsglTgsqService;

/**
 * 调岗调社申请Service业务层处理
 *
 * @author geyasong
 * @date 2024-12-02
 */
@Service
public class XsglTgsqServiceImpl implements IXsglTgsqService
{
    @Autowired
    private XsglTgsqMapper xsglTgsqMapper;

    /**
     * 查询调岗调社申请
     *
     * @param id 调岗调社申请主键
     * @return 调岗调社申请
     */
    @Override
    public XsglTgsq selectXsglTgsqById(String id)
    {
        return xsglTgsqMapper.selectXsglTgsqById(id);
    }

    /**
     * 查询调岗调社申请列表
     *
     * @param xsglTgsq 调岗调社申请
     * @return 调岗调社申请
     */
    @Override
    public List<XsglTgsq> selectXsglTgsqList(XsglTgsq xsglTgsq)
    {
        if(!(SecurityUtils.getUsername().equals("admin")||SecurityUtils.hasRole("guanli")
                ||SecurityUtils.getUsername().contains("x"))){
            xsglTgsq.setTgsqYxsds(SecurityUtils.getUsername());
            xsglTgsq.setTgsqXsds(SecurityUtils.getUsername());
        }
        return xsglTgsqMapper.selectXsglTgsqList(xsglTgsq);
    }

    /**
     * 新增调岗调社申请
     *
     * @param xsglTgsq 调岗调社申请
     * @return 结果
     */
    @Override
    public int insertXsglTgsq(XsglTgsq xsglTgsq)
    {
        xsglTgsq.setId(UUID.randomUUID().toString());
        //获取用户账号xsglXslb.setCreator(SecurityUtils.getUsername());
        //获取用户昵称
        xsglTgsq.setCreator(SecurityUtils.getLoginUser().getUser().getNickName());
        xsglTgsq.setCreatedate(DateUtils.getNowDate());
        return xsglTgsqMapper.insertXsglTgsq(xsglTgsq);
    }

    /**
     * 修改调岗调社申请
     *
     * @param xsglTgsq 调岗调社申请
     * @return 结果
     */
    @Override
    public int updateXsglTgsq(XsglTgsq xsglTgsq)
    {
        return xsglTgsqMapper.updateXsglTgsq(xsglTgsq);
    }

    /**
     * 批量删除调岗调社申请
     *
     * @param ids 需要删除的调岗调社申请主键
     * @return 结果
     */
    @Override
    public int deleteXsglTgsqByIds(String[] ids)
    {
        return xsglTgsqMapper.deleteXsglTgsqByIds(ids);
    }

    /**
     * 删除调岗调社申请信息
     *
     * @param id 调岗调社申请主键
     * @return 结果
     */
    @Override
    public int deleteXsglTgsqById(String id)
    {
        return xsglTgsqMapper.deleteXsglTgsqById(id);
    }
}
